<template>
    <div o-Container>
        <el-date-picker format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" v-model="value1" type="datetimerange" range-separator="至" start-placeholder="开始日期"
            end-placeholder="结束日期" @change="changeTime()" @clear="handleClear" :disabled="isEdit">
        </el-date-picker>
        {{ $attrs.isEdit }}
    </div>
</template>
<script>
export default {
    name: "data_picker", /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */
    props: {
        isEdit:{
            type:Boolean,
            default:true
        },
        time:{
            type:Array,
            default:[]
        }
    },
    // inject:['isEdit'],
    data() {
        return {
            octopus: this.$parent.octopus,
            value1: this.time,
            dateData: [],
        }
    },
    watch:{
        isEdit:{
            handler(e){
                console.log(e,'孙组件');
            }
        }
    },
    created() {
    },
    methods: {
        changeTime() {
            // let dates = []
            // if (this.value1) {
            //     this.value1.forEach(res => {
            //         console.log(res,'[[[]]]',new Date(res));
            //         // console.log(new Date(res).toISOString().slice(0, 10));
            //         dates.push(new Date(res).toISOString().slice(0, 10))
            //     });
            //     this.dateData = dates
            // } else {
            //     this.dateData = []
            // }

            this.$emit('timeList', this.value1);
        },
        handleClear() {
            this.dateData = []
            this.$emit('timeList', this.dateData);
        },
    },
}
</script>
<style scoped></style>